<template>
  <a-card :bordered="false" style="background:#fff !important">

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info"
           style="display:flex;padding-left: 10px; align-items: center; margin-bottom:10px">
        <!-- 查询区域 -->
        <div class="table-page-search-wrapper" style="flex:1;text-align: left;margin-bottom:0">
          <a-form layout="inline" @keyup.enter.native="searchQuery">
            <a-row :gutter="24">

              <a-col :xl="6" :lg="7" :md="8" :sm="24">
                <a-form-item style="margin-bottom:0 !important" label="审核状态">
                  <a-select v-model="queryParam.checkResult" placeholder="请选择审核状态" class="select-box">
                    <a-select-option value="">请选择</a-select-option>
                    <a-select-option value="0">待审核</a-select-option>
                    <a-select-option value="1">通过</a-select-option>
                    <a-select-option value="2">不通过</a-select-option>
                  </a-select>
                </a-form-item>
              </a-col>
              <a-col :xl="6" :lg="7" :md="8" :sm="24">
                <span style="float: left;overflow: hidden;margin-bottom:0 !important"
                      class="table-page-search-submitButtons">
                  <a-button type="primary" @click="searchQuery" icon="search" title="搜索" shape="circle"></a-button>
                  <a-button
                    type="primary"
                    @click="searchReset"
                    icon="reload"
                    style="margin-left: 8px"
                    title="重置"
                    shape="circle"></a-button>
                </span>
              </a-col>

            </a-row>
          </a-form>
        </div>

        <div>
          <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{
          selectedRowKeys.length }}</a>项
          <a style="margin-left: 24px" @click="onClearSelected">清空</a>
        </div>
      </div>

      <a-table
        ref="table"
        size="middle"
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        @change="handleTableChange">
        <span slot="action" slot-scope="text, record">
          <a @click="checkPass(record,1)" v-if="record.checkResult == 0 || record.checkResult == 2" title="通过">
            <a-icon type="check-circle" style="color:#35ab5f"/></a>
          <a @click="checkPass(record,2)" v-if="record.checkResult == 1" title="不通过">
            <a-icon type="close-circle" style="color:#ed7770"/></a>
        </span>
        <span slot="imgUrl1" slot-scope="text, record">
          <div style="width: 40px;height: 40px;" v-if="record.imgUrl1">
            <img style="width: 100%; height: 100%;" :src="record.imgUrl1"/>
          </div>
        </span>
        <span slot="imgUrl2" slot-scope="text, record">
          <div style="width: 40px;height: 40px;" v-if="record.imgUrl2">
            <img style="width: 100%; height: 100%;" :src="record.imgUrl2"/>
          </div>
        </span>
        <span slot="imgUrl3" slot-scope="text, record">
          <div style="width: 40px;height: 40px;" v-if="record.imgUrl3">
            <img style="width: 100%; height: 100%;" :src="record.imgUrl3"/>
          </div>
        </span>
        <span slot="imgUrl4" slot-scope="text, record">
          <div style="width: 40px;height: 40px;" v-if="record.imgUrl4">
            <img style="width: 100%; height: 100%;" :src="record.imgUrl4"/>
          </div>
        </span>
        <span slot="imgUrl15" slot-scope="text, record">
          <div style="width: 40px;height: 40px;" v-if="record.imgUrl5">
            <img style="width: 100%; height: 100%;" :src="record.imgUrl5"/>
          </div>
        </span>
      </a-table>
    </div>
    <!-- table区域-end -->
  </a-card>
</template>

<script>
  import {JeecgListMixin} from '@/mixins/JeecgListMixin'
  import {putAction} from '@/api/manage'

  export default {
    name: 'ConContentRemarkList',
    mixins: [JeecgListMixin],
    data() {
      return {
        description: '内容评论管理页面',
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key: 'rowIndex',
            width: 60,
            align: 'center',
            customRender: function (t, r, index) {
              return parseInt(index) + 1
            }
          },
          {
            title: '内容标题',
            align: 'center',
            dataIndex: 'title'
          },
          {
            title: '评论用户姓名',
            align: 'center',
            dataIndex: 'userName'
          },

          {
            title: '评论内容',
            align: 'center',
            ellipsis: true,
            width: 300,
            dataIndex: 'remarkContent'
          },
          {
            title: '点赞数',
            align: 'center',
            dataIndex: 'thumbsNum'
          },
          {
            title: '审核结果',
            align: 'center',
            dataIndex: 'checkResult',
            customRender: function (t, r, index) {
              return t == 0 ? '待审核' : t == 1 ? '通过' : '不通过'
            }
          },
          {
            title: '操作',
            dataIndex: 'action',
            align: 'center',
            scopedSlots: {customRender: 'action'}
          }
        ],
        url: {
          list: '/content/conContentRemark/list',
          edit: '/content/conContentRemark/edit'
        }
      }
    },
    computed: {},
    methods: {
      checkPass(record, value) {
        const param = {
          id: record.id,
          checkResult: value
        }
        putAction(this.url.edit, param).then(res => {
          if (res.success) {
            this.visible = false
            this.loadData(1)
          }
        })
      },
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>
